import React, { memo, useState } from 'react';
import Sun from './Sun';

const Father = memo(() => {
  const [count,setCount] = useState(0);
  function changeCountFu(num){
    console.log("count",count,'num',num);
    if(typeof num === 'object'){
      setCount(count+10)
    }else{
      setCount(count+num)
    }
  }
  return (
    <div>
      Father
      <hr />
      <h2>父组件的count :{count}</h2>
      <button onClick={changeCountFu}>父组件的按钮，修改count1</button>
      <hr />
      <button onClick={()=>changeCountFu(20)}>父修改count，带参数</button>
      <br />
      <hr />
      <Sun count={count} changeCountZi={changeCountFu}/>
    </div>
  )
})

export default Father